# Maintainer: Nick Østergaard <oe.nick at gmail dot com>

_realname=oce
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgver=0.17.2
pkgrel=4
pkgdesc="Open CASCADE Community Edition: patches/improvements/experiments contributed by users over the official Open CASCADE library."
url="https://github.com/tpaviot/oce"
arch=('any')
license=('LGPLv2.1')
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}-git")
makedepends=("${MINGW_PACKAGE_PREFIX}-cmake")
depends=("${MINGW_PACKAGE_PREFIX}-freetype")
#depends=('intel-tbb' 'gl2ps' 'freeimage' 'tk')
source=(https://github.com/tpaviot/${_realname}/archive/OCE-${pkgver}.tar.gz)
# 99_oce.sh 99_oce.conf)
install=oce-${CARCH}.install
sha256sums=('8d9995360cd531cbd4a7aa4ca5ed969f08ec7c7a37755e2f3d4ef832c1b2f56e')
         #'606e400a97d9947459e4de2eca65f04c'
         #'167a9f5c94a16d7855c3ac99e34a4506')

build() {
  #MAKEFLAGS=-j1
  cd oce-OCE-${pkgver}
  mkdir -p build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}
  flags=""
  flags="$flags -DOCE_INSTALL_PREFIX=${MINGW_PREFIX}"
  flags="$flags -DOCE_INSTALL_BIN_DIR=bin"
  flags="$flags -DOCE_INSTALL_LIB_DIR=lib"
  flags="$flags -DOCE_INSTALL_CMAKE_DATA_DIR=${MINGW_PREFIX}/lib/oce"
  flags="$flags -DOCE_AUTOINSTALL_DEPENDENT_LIBS=OFF"
  #flags="$flags -DOCE_MULTITHREAD_LIBRARY:STRING=TBB"
  #flags="$flags -DOCE_WITH_GL2PS=ON"
  #flags="$flags -DOCE_WITH_FREEIMAGE=ON"
  #flags="$flags -DOCE_DRAW=ON"
  flags="$flags -DCMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS=1"
  flags="$flags -DCMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS=1"
  flags="$flags -DCMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES=1"
  flags="$flags -DCMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES=1"
  flags="$flags -DCMAKE_C_RESPONSE_FILE_LINK_FLAG=@ "
  flags="$flags -DCMAKE_CXX_RESPONSE_FILE_LINK_FLAG=@"

  MSYS2_ARG_CONV_EXCL="-DCMAKE_PREFIX_PATH=;-DCMAKE_INSTALL_PREFIX=;-DOCE_INSTALL_PREFIX=;-DOCE_INSTALL_CMAKE_DATA_DIR=;-DOCE_INSTALL_BIN_DIR=;-DOCE_INSTALL_LIB_DIR=" \
  ${MINGW_PREFIX}/bin/cmake.exe \
  -G"MSYS Makefiles" \
  -DCMAKE_PREFIX_PATH=${MINGW_PREFIX} \
  -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
  $flags ..
  
  make
}

package() {
  cd oce-OCE-${pkgver}/build-${MINGW_CHOST}
  make DESTDIR="${pkgdir}" install
  install -Dm644 ${srcdir}/oce-OCE-${pkgver}/LICENSE_LGPL_21.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE_LGPL_21.txt"
  install -Dm644 ${srcdir}/oce-OCE-${pkgver}/OCCT_LGPL_EXCEPTION.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/OCCT_LGPL_EXCEPTION.txt"
  
  #install -m644 -D "${srcdir}/99_oce.conf" -t "${pkgdir}/etc/ld.so.conf.d"
  #install -m755 -D "${srcdir}/99_oce.sh" -t "${pkgdir}/etc/profile.d"
}

# vim:set ts=2 sw=2 et:
